//======================================================================================
/** \file  avr_adc.h
 *    This file contains a very, very simple A/D converter driver. WARNING: It has bugs!
 *    It's only here as an example. It should not be used in a meaningful project. 
 *
 *  Revisions:
 *    \li  01-15-08 JRR Original (somewhat useful) file
 *
 *  License:
 *    This file released under the Lesser GNU Public License. The program is intended
 *    for educational use only, but its use is not restricted thereto. 
 */
//======================================================================================

#ifndef _AVR_ADC_H_                         // To prevent *.h file from being included
#define _AVR_ADC_H_                         // in a source file more than once

#include "base_text_serial.h"				// Header for serial ports and devices


//-------------------------------------------------------------------------------------
/** This class should run the A/D converter on an AVR processor. It should have some
 *  better comments. 
 */

class avr_adc
    {
    protected:
        /// The ADC class uses this pointer to the serial port to say hello
        base_text_serial* ptr_to_serial;

    public:
        // The constructor just says hello at the moment, using the serial port which
        // is specified in the pointer given to it
        avr_adc (base_text_serial* = NULL);

        // This function reads one channel once, returning the result as an unsigned 
		// integer. The parameter is the channel number 
        unsigned int read_once (unsigned char);
		
		// This method reads the A/D twice and throws out the first reading
		unsigned int read_twice (unsigned char);
		
		// This method reads the A/D a bunch of times and computes the average
		uint16_t read_oversampled (uint8_t, uint8_t);
    };

#endif // _AVR_ADC_H_
